package com.heye.imheye.ws;

import lombok.Getter;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class WsContainer {

    @Getter
    private final Map<Long, WebSocketSession> sessions = new ConcurrentHashMap<>();

    public void put(Long userId, WebSocketSession session) {
        sessions.put(userId, session);
    }

    public WebSocketSession getSessionByUserId(Long userId) {
        return sessions.get(userId);
    }
}
